<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * 개별이용권 구매를 담당
 */
class Ticket_model extends CI_Model {

	function __construct() {
		parent::__construct();

		$this->load->library('LogSql');
	}

	/**
	 * 개별이용권 지급 처리
	 */
	function insert_ticket($user_id, $service_group_id, $service_id, $start_dt) {
		log_message('debug',"#### Ticket_model::insert_ticket($user_id, $service_group_id, $service_id, $start_dt)");
		
		$this->db->set('user_id'         , $user_id);
		$this->db->set('service_group_id', $service_group_id);
		$this->db->set('service_id'      , $service_id);
		$this->db->set('used_yn'         , 'N');
		$this->db->set('start_dt'        , $start_dt);
		$this->db->set('end_dt'          , "DATE_FORMAT(DATE_ADD(STR_TO_DATE('$start_dt','%Y%m%d'), INTERVAL 1 YEAR),'%Y%m%d')", FALSE);
		$this->db->set('create_dt'       , 'now()', FALSE);
		$this->db->set('update_dt'       , 'now()', FALSE);
		$this->db->insert('tb_ticket') or $this->logsql->log_sql('error');

		$this->logsql->log_sql();
	}
}

/* End of file ticket_model.php */
/* Location: ./application/models/package/ticket_model.php */